package demo01;

import java.io.File;

public class demo01 {
    public static void main(String[] args) {
        //1. 获取本机盘符
        File[] roots = File.listRoots();
        for (int i = 0; i < roots.length; i++) {
            System.out.print(roots[i].getPath() + "; ");//磁盘路径
            System.out.print(roots[i].getTotalSpace() / 1024 / 1024 / 1024 + "; ");//磁盘总空间大小
            System.out.print(roots[i].getUsableSpace() / 1024 / 1024 / 1024 + "; ");//剩余磁盘空间大小
            System.out.println(roots[i].getFreeSpace() / 1024 / 1024 / 1024);//剩余磁盘空间大小
        }
    }
}
